from app_obj import *
from threading import Thread

def works_thread(start_args,try_count = TRY_COUNT):
    works = []
    logger.debug("待连接设备列表 : {}".format(start_args))
    for args in start_args:
        desired_capabilities = args['desired_capabilities']
        DRIVER_SERVER = args['DRIVER_SERVER']
        deviceName = desired_capabilities["deviceName"]
        logger.debug("链接到设备 : {}".format(deviceName))
        work = Thread(target = work_start,name = deviceName ,args = (desired_capabilities,DRIVER_SERVER,try_count))
        works.append(work)

    for work in works:
        work.setDaemon(True) # 守护线程
        work.start()
        time.sleep(20)
    
    for work in works:
        work.join() # 阻塞线程


def main():
    
	works_thread(start_args,try_count=1000)


if __name__ == '__main__':
    main()